package jmine.tec.subscription.impl;

import jmine.tec.annotations.Unmodifiable;

/**
 * @author takeshi
 */
@Unmodifiable
public class BlaPublication extends AbstractPublication {

    private final long value;

    private final RuntimeException creationStack = new RuntimeException() {
        public synchronized Throwable fillInStackTrace() {
            return null;
        };
    };

    private final String thread = Thread.currentThread().getName();

    public BlaPublication(long value) {
        super("ping");
        this.value = value;
    }

    public long getValue() {
        return this.value;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#hashCode()
     */

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (this.value ^ (this.value >>> 32));
        return result;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        BlaPublication other = (BlaPublication) obj;
        if (this.value != other.value) {
            return false;
        }
        return true;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#toString()
     */

    @Override
    public String toString() {
        return "BlaPublication [value=" + value + ",   version: " + this.getLocalVersion() + "]";
    }

    public void printStackTrace() {
        this.creationStack.printStackTrace();
        System.err.println("created by: " + this.thread);
    }

}
